package com.java.multipledatasource.spring.proxy;

import com.java.multipledatasource.spring.mapper.UserMapper;
import org.springframework.cglib.proxy.InvocationHandler;
import org.springframework.cglib.proxy.Proxy;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @author hu
 * @version 1.0
 * @date 2020/12/7 0007 下午 8:48
 */
public class UserMapperProxy {
    public static void main(String[] args) {
        UserMapper userMapper =(UserMapper) Proxy.newProxyInstance(UserMapperProxy.class.getClassLoader(), new Class[]{UserMapper.class}, new InvocationHandler() {
            @Override
            public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
                System.out.println("name: " +  method.getName());
                System.out.println(Arrays.toString(method.getGenericParameterTypes()));
                return null;
            }
        });

        userMapper.findDetailByIdAndAge("123", 20);

        userMapper.findList();
    }
}
